package com.hktf.uilib.utils;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

import com.hktf.uilib.R;


/**
 * Created by Administrator on 2017/1/17.
 */
public class SoundPlayUtilsNew {

    public static SoundPool mSoundPlayer = new SoundPool(10,
            AudioManager.STREAM_SYSTEM, 5);
    public static SoundPlayUtilsNew soundPlayUtils;
    // 上下文
    static Context mContext;

    /**
     * 初始化
     *
     * @param context
     */
    public static SoundPlayUtilsNew init(Context context) {
        if (soundPlayUtils == null) {
            soundPlayUtils = new SoundPlayUtilsNew();
            // 初始化声音
            mContext = context;
            mSoundPlayer.load(mContext, R.raw.notice, 1);// 1
        }




        return soundPlayUtils;
    }

    /**
     * 播放声音
     *
     * @param soundID
     */
    public static void play(int soundID) {
        mSoundPlayer.play(soundID, 1, 1, 0, 0, 1);
    }

    public static void pause(int soundID) {
        mSoundPlayer.pause(soundID);
    }
}
